{
Function:		_TickSeconds(CalcSeconds):

Purpose:		Timer function used to prevent calculations from occuring more frequently than 
				once every CalcSeconds
	
Description:	Returns:
					=2, End of Bar Trigger, calculations should be done
					=1,	CalcSeconds exceeded since last calculation, calculations should be done
					=0, CalcSeconds not reached since last calculation, NO calculations should be done

				If input CalcSeconds <=0 then function returns 2, indicating calculations should be
				done with each tick.

Source:			Modified from Goose's TamedAlert concept

Author:			MarkSanDiego

Updated:		01/05/05	original version
				12/31/08	slightly faster logic
}
					

inputs:
	CalcSeconds(NumericSimple);

vars:
	intrabarpersist LastTick(0),
	intrabarpersist	NextCalcTime(0),
	NextCalc(CalcSeconds*0.000011574);

if CalcSeconds <= 0 then begin
	_TickSeconds = 2;											// trigger each tick if CalcSeconds <= 0

end else if barstatus(1) <= 1 then begin
	if ComputerDateTime >= NextCalcTime then begin				// timed trigger beginning of or intrabar
		NextCalcTime = ComputerDateTime + NextCalc ;  
		_TickSeconds = 1;	
	end else 
		_TickSeconds = 0;

end else begin
	_TickSeconds = 2;											// end of bar trigger
end;



